package cn.achao.csr.chat.controller;

import cn.achao.csr.api.model.resp.ChatRoomResp;
import cn.achao.csr.base.resp.CursorPageBaseResp;
import cn.achao.csr.base.resp.R;
import cn.achao.csr.chat.service.ChatRoomService;
import cn.achao.csr.mybatis.req.MPBaseCursorPageReq;
import cn.achao.csr.security.utils.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Author: achao
 **/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/contact")
public class ChatContactController {

    private final ChatRoomService roomService;

    /**
     * 会话房间列表（支持未登录）
     * @param request
     * @return
     */
    @GetMapping("/page")
    public R<CursorPageBaseResp<ChatRoomResp>> getRoomPage(@Valid MPBaseCursorPageReq request) {
        Long uid = SecurityUtils.getUserId();
        return R.ok(roomService.getContactPage(request, uid));
    }


}
